package com.example.eureka;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.client.RestTemplate;

@Controller
@Configuration
public class InvokerController {
    @LoadBalanced
    @Bean
    RestTemplate loadBalanced() {
        return new RestTemplate();
    }

    @Autowired
    private RestTemplate loadBalanced;

    @RequestMapping("/orderFood1")
    @ResponseBody 
    public String orderFood1() {
        return loadBalanced.getForObject("http://eureka-provider/orderFood/1", String.class);
    }

    @RequestMapping("/orderFood2")
    @ResponseBody 
    public String orderFood2() {
    	 return loadBalanced.getForObject("http://eureka-provider/orderFood/2", String.class);
    }      
}



